package com.suypower.carManage.action;

import javax.servlet.ServletException;

import com.jarp.db.DAO;
import com.opensymphony.xwork2.ActionSupport;
import com.suypower.carManage.comm.ConstUtil;

public class DriverAction extends ActionSupport {

	private String id;
	private String name;
	private String sex;
	private String property;
	private String born;
	private String id_code;
	private String phone_num;
	private String car_model;
	private String sideline;
	private String glory;
        private String ab;
	private String experience;
	private String head_image;
        private String workage;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getProperty() {
		return property;
	}

	public void setProperty(String property) {
		this.property = property;
	}

	public String getBorn() {
		return born;
	}

	public void setBorn(String born) {
		this.born = born;
	}

	public String getId_code() {
		return id_code;
	}

	public void setId_code(String idCode) {
		id_code = idCode;
	}

	public String getPhone_num() {
		return phone_num;
	}

	public void setPhone_num(String phoneNum) {
		phone_num = phoneNum;
	}

	public String getCar_model() {
		return car_model;
	}

	public void setCar_model(String carModel) {
		car_model = carModel;
	}

	public String getSideline() {
		return sideline;
	}

	public void setSideline(String sideline) {
		this.sideline = sideline;
	}

    public String getAb() {
        return ab;
    }

    public void setAb(String ab) {
        this.ab = ab;
    }
        

	public String execute() {
		String res = "";
		DAO dao = new DAO();
		String sql = "";
		if (id != null && !id.equals("")) {
			sql = "UPDATE tb_driver SET name = '" + name + "',head_image='"+head_image+"',experience='"+experience+"',glory='"+glory+"', sex = '" + sex
					+ "', born = '" + born
					+ "', id_code = '" + id_code + "', phone_num = '"
					+ phone_num + "', car_model = '" + car_model
					+ "', sideline = '" + sideline+"',ab='"+ab + "',workage = '"+workage +"' where id=" + id;
		} else {
			sql = "INSERT INTO tb_driver(name,sex,experience,glory,ab,head_image,born,id_code,phone_num,car_model,sideline,workage)VALUES('"
					+ name
					+ "','"
					+ sex
					+ "','"
					+ experience
					+ "','"
					+ glory
					+ "','"
                                        + ab
					+ "','"
					+ head_image
					+ "','"
					+ born
					+ "','"
					+ id_code
					+ "','"
					+ phone_num
					+ "','"
					+ car_model
					+ "','" + sideline + "','"
                                        +workage + "')";
		}
		int count = 0;
		try {
			count = dao.execCommand(ConstUtil.DBNAME, sql);
			if (count > 0) {
				res = this.SUCCESS;
			} else {
				res = this.ERROR;
			}
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return res;
	}

	public String getGlory() {
		return glory;
	}

	public void setGlory(String glory) {
		this.glory = glory;
	}

	public String getExperience() {
		return experience;
	}

	public void setExperience(String experience) {
		this.experience = experience;
	}

	public String getHead_image() {
		return head_image;
	}

	public void setHead_image(String headImage) {
		head_image = headImage;
	}

    public String getWorkage() {
        return workage;
    }

    public void setWorkage(String workage) {
        this.workage = workage;
    }
	
	
}
